using Mono.Cecil;
using Mono.Cecil.Cil;

namespace Cil.Ast;

public sealed class PtrCastToMethodHandlerExpression : SingleInstructionExpression
{
	public PtrCastToMethodHandlerExpression(Context context, Instruction position, MethodReference ref_method)
		: base(context, position)
	{
		// base class
		ReadsStack = 1;
		WritesStack = 1;
		ReturnType = Context.MakeRef<IntPtr>();
		Nodes = new FixedList<Expression>();

		// this class
		MethodReference = ref_method;
	}

	public MethodReference MethodReference { get; private set; }

	public override string ToString()
	{
		return string.Format("/*methodof*/{0}", MethodReference.Name);
	}
}

public static partial class IlAst
{
	public static PtrCastToMethodHandlerExpression PtrCastToMethodHandler(Context context, Instruction position, MethodReference ref_method)
	{
		return new PtrCastToMethodHandlerExpression(context, position, ref_method);
	}
}